/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.stylefeng.guns.modular.grape.enums;

import static org.apache.commons.lang3.ArrayUtils.isNotEmpty;
import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase;
import static org.apache.commons.lang3.StringUtils.startsWithIgnoreCase;

/**
 *
 * @author wmao
 */
public enum AuthEnum {
    PAY("pay"), LANDING("landing"), ORDER("order"), CLEARANCE("clearance");
    private final String name;

    AuthEnum(String name) {
        this.name = name;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }
    
    public static AuthEnum getByName(String name){
        AuthEnum[] values = AuthEnum.values();
        if (isNotEmpty(values)) {
            for (AuthEnum exclude : values) {
                if (equalsIgnoreCase(name, exclude.getName())) {
                    return exclude;
                }
            }
        }
        return null;
    }

    public static boolean containName(String name) {
        AuthEnum[] values = AuthEnum.values();
        if (isNotEmpty(values)) {
            for (AuthEnum exclude : values) {
                if (startsWithIgnoreCase(name, exclude.getName())) {
                    return true;
                }
            }
        }
        return false;
    }

}
